#include <stdio.h>

int sum(int a[][2], int rows) {
  int result = 0;
  for (int i = 0; i < rows; i++) {
    for (int j = 0; j < 2; j++) {
      result += *(*(a + i) + j);
    }
  }
  return result;
}

int main() {
  int a[3][2] = {{1, 4}, {9, 16}, {25, 36}};
  int result = sum(a, 3);
  printf("%d\n", result);
}